
package lyxs_916.drawabletest;

import android.graphics.drawable.TransitionDrawable;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;

public class TransitionDrawableActivity extends AppCompatActivity {
    ImageView iv;

    TransitionDrawable transition;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_transition);

        iv = (ImageView) findViewById(R.id.image);
        iv.setImageLevel(4);
        transition = (TransitionDrawable) iv.getDrawable();

        findViewById(R.id.on).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                transition.startTransition(3000);

            }
        });

        findViewById(R.id.off).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                transition.reverseTransition(3000);

            }
        });


    }


}
